package org.beetl.json;

import java.io.IOException;
import java.io.Writer;
import java.util.List;
import org.beetl.json.action.KeyAction;
import org.beetl.json.action.ValueAction;

public abstract class AbstractOutputNode implements OutputNode {
	
	
	protected KeyAction keyAction = null;
	protected ValueAction valueAction = null;
	
	public abstract void render(Object obj, Writer w,String after)  throws IOException ;
	public void scope(Location loc){
		List<Location> allLocation = loc.children;
		for(Location l:allLocation){
			if(isMatch(l)){
				LocationAction action = l.getAction();
				if(action instanceof KeyAction){
					this.keyAction = (KeyAction)action;
				}else if(action instanceof ValueAction){
					this.valueAction = (ValueAction)action;
				}
			}
		}
		
		
	}
	protected abstract boolean isMatch(Location location);

}
